package com.cs410.collabwriting.test;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import com.cs410.collabwriting.tools.DatabaseManager;
import com.cs410.collabwriting.tools.LogManager;

public class DatabaseUtility {
	
	private static long SLEEP_TIME = 1000;
	
	private DatabaseUtility() {
		
	}
	
	public static void CreateAllTables() {
		String [] CreateTableQueries = {
			"CREATE TABLE USER_TABLE( userid VARCHAR(32) , password CHAR(16) NOT NULL, email varchar(32), firstname VARCHAR(24), lastname VARCHAR(24), biography VARCHAR(4096), location VARCHAR(32), gender CHAR(8), dateCreated DATE, lastUpdate TIMESTAMP, activateKey VARCHAR(64), PRIMARY KEY(userid))",
            "CREATE TABLE SUBSCRIBED_USER_TABLE( userid VARCHAR(32), favuserid VARCHAR(32), PRIMARY KEY(userid, favuserid), FOREIGN KEY(userid) REFERENCES USER_TABLE(userid), FOREIGN KEY(favuserid) REFERENCES USER_TABLE(userid))",
			"CREATE TABLE PROMPT_TABLE( promptid INT NOT NULL AUTO_INCREMENT, prompt VARCHAR(1028), imagePath VARCHAR(1028), userid VARCHAR(32) NOT NULL, timestamp DATE, active BOOLEAN DEFAULT 1, PRIMARY KEY(promptid), FOREIGN KEY(userid) REFERENCES USER_TABLE(userid) ON DELETE CASCADE)",

			"CREATE TABLE STORY_TABLE( storyid INT NOT NULL AUTO_INCREMENT, storytitle VARCHAR(140) NOT NULL, promptid INT, timestamp DATETIME, userid VARCHAR(32), viewcount INT DEFAULT 0, votecount INT DEFAULT 0, PRIMARY KEY(storyid), FOREIGN KEY(promptid) REFERENCES PROMPT_TABLE(promptid) ON DELETE CASCADE, FOREIGN KEY(userid) REFERENCES USER_TABLE(userid) ON DELETE CASCADE)",
			
			"CREATE TABLE STORYLISTNAME_TABLE( listid INT NOT NULL AUTO_INCREMENT UNIQUE, userid VARCHAR(32), name VARCHAR(128), PRIMARY KEY(listid, userid), FOREIGN KEY(userid) REFERENCES USER_TABLE(userid) ON DELETE CASCADE)",
			"CREATE TABLE STORYLIST_TABLE( storyid INT, listid INT, PRIMARY KEY(storyid, listid), FOREIGN KEY(storyid) REFERENCES STORY_TABLE(storyid), FOREIGN KEY(listid) REFERENCES STORYLISTNAME_TABLE(listid) ON DELETE CASCADE)",
			"CREATE TABLE SUBSCRIBED_STORY_TABLE( userid VARCHAR(32), storyid INT, PRIMARY KEY(userid, storyid), FOREIGN KEY(userid) REFERENCES USER_TABLE(userid), FOREIGN KEY(storyid) REFERENCES STORY_TABLE(storyid) ON DELETE CASCADE)",
			"CREATE TABLE TAG_TABLE( storyid INT, tag VARCHAR(24), userid VARCHAR(32), PRIMARY KEY(storyid, tag, userid), FOREIGN KEY(storyid) REFERENCES STORY_TABLE(storyid), FOREIGN KEY(userid) REFERENCES USER_TABLE(userid) ON DELETE CASCADE)",
			"CREATE TABLE UPVOTE_TABLE( userid VARCHAR(32), storyid INT, timestamp DATETIME, PRIMARY KEY(userid, storyid, timestamp), FOREIGN KEY(userid) REFERENCES USER_TABLE(userid) ON DELETE CASCADE, FOREIGN KEY(storyid) REFERENCES STORY_TABLE(storyid) ON DELETE CASCADE)",
			"CREATE TABLE COMMENT_TABLE( storyid INT, commentid INT NOT NULL AUTO_INCREMENT, userid VARCHAR(32), timestamp DATETIME, comment VARCHAR(4096), PRIMARY KEY(commentid), FOREIGN KEY(storyid) REFERENCES STORY_TABLE(storyid) ON DELETE CASCADE, FOREIGN KEY(userid) REFERENCES USER_TABLE(userid) ON DELETE CASCADE)",
			"CREATE TABLE POST_TABLE( postid INT NOT NULL AUTO_INCREMENT, storyid INT, userid VARCHAR(32), timestamp TIMESTAMP, post VARCHAR(4096), PRIMARY KEY(postid), FOREIGN KEY(storyid) REFERENCES STORY_TABLE(storyid) ON DELETE CASCADE, FOREIGN KEY(userid) REFERENCES USER_TABLE(userid) ON DELETE CASCADE)",
			"CREATE TRIGGER dateUserCreatedInsert BEFORE INSERT ON USER_TABLE FOR EACH ROW BEGIN SET NEW.DATECREATED = NOW(); SET NEW.LASTUPDATE = NOW(); END;",
			//"CREATE TRIGGER dateUserUpdateInsert BEFORE INSERT ON USER_TABLE FOR EACH ROW SET NEW.LASTUPDATE = NOW()",
			"CREATE TRIGGER datePromptInsert BEFORE INSERT ON PROMPT_TABLE FOR EACH ROW SET NEW.TIMESTAMP = NOW()",
			"CREATE TRIGGER dateStoryInsert BEFORE INSERT ON STORY_TABLE FOR EACH ROW SET NEW.TIMESTAMP = NOW()",
			"CREATE TRIGGER dateUpvotesInsert BEFORE INSERT ON UPVOTE_TABLE FOR EACH ROW SET NEW.TIMESTAMP = NOW()",
			"CREATE TRIGGER dateCommentsInsert BEFORE INSERT ON COMMENT_TABLE FOR EACH ROW SET NEW.TIMESTAMP = NOW()",
			"CREATE TRIGGER datePostInsert BEFORE INSERT ON POST_TABLE FOR EACH ROW SET NEW.TIMESTAMP = NOW()" 
		};
		
		for( int i = 0; i < CreateTableQueries.length; i++ ) {
			DatabaseManager.executeUpdate( CreateTableQueries[i] );
		}
	}
	
	public static void DeleteAllTables() {
		String [] DeleteTableQueries = {
			"DROP TABLE POST_TABLE CASCADE",
			"DROP TABLE COMMENT_TABLE CASCADE",
			"DROP TABLE UPVOTE_TABLE CASCADE",
			"DROP TABLE TAG_TABLE CASCADE",
			"DROP TABLE SUBSCRIBED_STORY_TABLE CASCADE",
			"DROP TABLE STORYLIST_TABLE CASCADE",
            "DROP TABLE STORYLISTNAME_TABLE CASCADE",
			"DROP TABLE STORY_TABLE CASCADE",
			"DROP TABLE PROMPT_TABLE CASCADE",
			"DROP TABLE SUBSCRIBED_USER_TABLE CASCADE",
			"DROP TABLE USER_TABLE CASCADE",
//			"DROP TABLE COMMENTS_TABLE CASCADE",
//			"DROP TABLE UPVOTES_TABLE CASCADE",
//			"DROP TABLE TAGS_TABLE CASCADE",
		};
		
		for( int i = 0; i < DeleteTableQueries.length; i++ ) {
			DatabaseManager.executeUpdate( DeleteTableQueries[i] );
		}
	}
	
	public static void ResetDatabaseToDefaults() {
		DeleteAllTables();
		CreateAllTables();
	}	
	
	public static void CreateAllTestingData() {
		CreateUserTestingData();
		CreateUserSubscriptionTestData();
		CreatePromptTestingData();
		CreateStoryTestingData();
		CreateStoryListNameTestingData();
		CreateStoryListTestingData();
		CreateSubscribedStoryTestingData();
		CreateTagsTestingData();
		CreateUpvotesTestingData();
		CreateCommentsTestingData();
		CreatePostsTestingData();
	}
	
	public static void CreateUserTestingData() {
		MessageDigest d = null;
		try {
			d = java.security.MessageDigest.getInstance("MD5");
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		String[] password = new String[6];
		password[0] = "HIJKLMNOP";
		password[1] = "justine";
		password[2] = "mitchell";
		password[3] = "angie";
		password[4] = "cary";
		password[5] = "username";
		for (int i = 0; i < password.length; i++) {
			String encryptedPassword = new String (d.digest(password[i].getBytes()));
			password[i] = encryptedPassword;
		}
		String[] QueryList = {
				"INSERT INTO USER_TABLE(USERID,PASSWORD,EMAIL,FIRSTNAME,LASTNAME,BIOGRAPHY,LOCATION,GENDER,ACTIVATEKEY) VALUES ('ABCDEFG', '" + password[0] + "', 'lsnkay@gmail.com', 'Alphabet', 'Man', 'I LIKE ALPHABETS', 'Xyz St. LetterCity, AlphabetLand', 'BOTH', '0')",
				"INSERT INTO USER_TABLE(USERID,PASSWORD,EMAIL,FIRSTNAME,LASTNAME,BIOGRAPHY,LOCATION,GENDER,ACTIVATEKEY) VALUES ('justine', '" + password[1] + "', 'jleung1989@gmail.com', 'Justine', 'Leung', 'I r Guy.', 'Some St. Vancouver BC., Canada', 'FEMALE', '0')",
				"INSERT INTO USER_TABLE(USERID,PASSWORD,EMAIL,FIRSTNAME,LASTNAME,BIOGRAPHY,LOCATION,GENDER,ACTIVATEKEY) VALUES ('mitchell', '" + password[2] + "', 'lsnkay@gmail.com', 'Mitchell', 'Chuang', 'I r Girl1', 'Some St. Vancouver BC., Canada', 'MALE', '0')",
				"INSERT INTO USER_TABLE(USERID,PASSWORD,EMAIL,FIRSTNAME,LASTNAME,BIOGRAPHY,LOCATION,GENDER,ACTIVATEKEY) VALUES ('angie', '" + password[3] + "', 'lsnkay@gmail.com', 'Angie', 'Cheung', 'I r Girl2', 'Some St. Vancouver BC., Canada', 'MALE', '0')",
				"INSERT INTO USER_TABLE(USERID,PASSWORD,EMAIL,FIRSTNAME,LASTNAME,BIOGRAPHY,LOCATION,GENDER,ACTIVATEKEY) VALUES ('cary', '" + password[4] + "', 'lsnkay@gmail.com', 'Cary', 'Cheung', 'I r Girl3', 'Some St. Vancouver BC., Canada', 'MALE', '0')",
				"INSERT INTO USER_TABLE(USERID,PASSWORD,EMAIL,FIRSTNAME,LASTNAME,BIOGRAPHY,LOCATION,GENDER,ACTIVATEKEY) VALUES ('username', '" + password[5] + "', 'lsnkay@gmail.com', 'Username', 'Password', '!Sense', 'Digital World', 'BOTH', '0')"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
		}
	}
	
	public static void CreateUserSubscriptionTestData() {
		String[] QueryList = {
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'ABCDEFG', 'justine' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'ABCDEFG', 'mitchell' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'ABCDEFG', 'cary' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'justine', 'ABCDEFG' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'justine', 'username')",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'mitchell', 'angie' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'angie',' justine' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'angie', 'mitchell' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'angie', 'cary' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'angie', 'username' )",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'angie', 'ABCDEFG')",
				"INSERT INTO SUBSCRIBED_USER_TABLE(userid, favuserid) VALUES ( 'cary', 'justine' )"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
		}
	}
		
	public static void CreatePromptTestingData() {
		String[] QueryList = {
				"INSERT INTO PROMPT_TABLE(PROMPT, USERID) VALUES ('The quick brown fox jumps over the lazy dog.', 'ABCDEFG')",
				"INSERT INTO PROMPT_TABLE(IMAGEPATH, USERID) VALUES ('http://www.google.com/logos/2011/lebanon-2011-hp.jpg', 'justine')",
				"INSERT INTO PROMPT_TABLE(PROMPT, IMAGEPATH, USERID) VALUES ('An Amazing Idea.', 'http://www.google.com/logos/2011/hua_luogeng-2011-hp.jpg', 'username')",
				"INSERT INTO PROMPT_TABLE(PROMPT, USERID) VALUES ('Orange for your thought?', 'ABCDEFG')",
				"INSERT INTO PROMPT_TABLE(PROMPT, USERID) VALUES ('Starbucks', 'angie')",
				"INSERT INTO PROMPT_TABLE(PROMPT, USERID) VALUES ('Eco-unfriendly Double Cupped Venti EGTL', 'justine')",
				"INSERT INTO PROMPT_TABLE(PROMPT, IMAGEPATH, USERID) VALUES ('Christmas Time & Presents', 'http://www.google.com/logos/2011/veterans_day-2011-hp.jpg', 'username')"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
		}	
	}
	
	public static void CreateStoryTestingData() {
		String[] QueryList = {
				"INSERT INTO STORY_TABLE(STORYTITLE, PROMPTID, USERID, VIEWCOUNT) VALUES ('The Alphabet Game', 0, 'ABCDEFG', 1)",
				"INSERT INTO STORY_TABLE(STORYTITLE, USERID, VIEWCOUNT) VALUES ('Project within a Project', 'justine', 3)",
				"INSERT INTO STORY_TABLE(STORYTITLE, PROMPTID, USERID, VIEWCOUNT) VALUES ('Project Inception of Project', 3, 'angie', 2)",
				"INSERT INTO STORY_TABLE(STORYTITLE, PROMPTID, USERID, VIEWCOUNT) VALUES ('Guys Guys and more Guys', 1, 'mitchell', 10)",
				"INSERT INTO STORY_TABLE(STORYTITLE, USERID, VIEWCOUNT) VALUES ('Ho Ho Ho, Merry Christmas!', 'ABCDEFG', 7)",
				"INSERT INTO STORY_TABLE(STORYTITLE, USERID, VIEWCOUNT) VALUES ('Ho Ho Ho, Merry Christmas!', 'username', 2)"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
			try {
				Thread.sleep(SLEEP_TIME);
			} catch(Exception e) {
				LogManager.logError( "[DatabaseUtility] - " + e.getMessage() );
			}
		}
	}
	
	public static void CreateStoryListNameTestingData() {
		String[] QueryList = {
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'ABCDEFG', 'My Alphabets Collection' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'angie', 'super epic awesome stories' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'mitchell', 'super epic awesome stories' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'mitchell', 'all time favorites' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'cary', 'all time favorites' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'angie', 'all time favorites' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'cary', 'x-mas stories' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'angie', 'the cult of angie' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'mitchell', 'stories club' ) ",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'cary', 'stories club' )",
				"INSERT INTO STORYLISTNAME_TABLE( USERID, NAME ) VALUES ( 'mitchell', 'interesting stories' ) "
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
		}
	}
	
	public static void CreateStoryListTestingData() {
		
	}
	
	public static void CreateSubscribedStoryTestingData() {
		String[] QueryList = {
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'ABCDEFGH', 3 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'mitchell', 3 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'cary', 3 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'username', 3 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'username', 2 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'username', 0 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'username', 4 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'mitchell', 5 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'username', 5 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'mitchell', 4 )",
				"INSERT INTO SUBSCRIBED_STORY_TABLE(USERID,STORYID) VALUES ( 'cary', 1 )"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
		}
	}
	
	public static void CreateTagsTestingData() {
		String[] QueryList = {
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 6, 'FANTASY', 'ABCDEFG' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 6, 'FANTASY', 'justine' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 6, 'FANTASY', 'cary' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 6, 'FANTASY', 'angie' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 6, 'FANTASY', 'mitchell' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 6, 'FANTASY', 'username' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 1, 'FANTASY', 'ABCDEFG' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 2, 'FANTASY', 'justine' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 3, 'FANTASY', 'cary' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 4, 'FANTASY', 'angie' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 5, 'FANTASY', 'mitchell' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 1, 'COMEDY', 'username' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 1, 'COMEDY', 'angie' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 4, 'HORROR', 'cary' ) ",
				"INSERT INTO TAG_TABLE( STORYID, TAG, USERID ) VALUES ( 5, 'ROMANCE', 'mitchell' ) ",
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
		}
	}
	
	public static void CreateUpvotesTestingData() {
		String[] QueryList = {
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'ABCDEFGH', 3 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'mitchell', 3 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'cary', 3 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'username', 3 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'username', 2 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'username', 4 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'mitchell', 5 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'username', 5 )",
				"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'mitchell', 4 )",
		//		"INSERT INTO UPVOTE_TABLE(USERID,STORYID) VALUES ( 'cary', 1 )"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
		}
	}
	
	public static void CreateCommentsTestingData() {
		String[] QueryList = {
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 6 , 'ABCDEFG', 'Why Isn''t this about alphabets?' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 1 , 'cary', 'Cool Story' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 2 , 'username', 'I don''t get it.' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 3 , 'username', 'What? This is confusing' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 6 , 'angie', '1 2 3 4 5 6 7 8 9.........' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 6 , 'mitchell', 'What''s an alphabet?' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 5 , 'username', 'Is that even english?' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 6 , 'justine', 'hahahahahahahahahahahahahahahaha' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 4 , 'angie', 'WOW' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 3 , 'cary', 'it''s so easy to understand!' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 2 , 'justine', 'doh.' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 6 , 'ABCDEFG', 'You guys are mean! You''re hurting my feelings' )",
				"INSERT INTO COMMENT_TABLE( STORYID, USERID, COMMENT ) VALUES ( 5 , 'mitchell', 'Could be better.....' )"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
			try {
				Thread.sleep(SLEEP_TIME);
			} catch(Exception e) {
				LogManager.logError( "[DatabaseUtility] - " + e.getMessage() );
			}
		}
	}
	
	public static void CreatePostsTestingData() {
		String[] QueryList = {
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 3, 'angie', 'Marley was dead: to begin with. There is no doubt whatever about that. The register of his burial was signed by the clergyman, the clerk, the undertaker, and the chief mourner. Scrooge signed it: and Scrooge''s name was good upon ''Change, for anything he chose to put his hand to. Old Marley was as dead as a door-nail.' )",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 3, 'cary', 'Mind! I don''t mean to say that I know, of my own knowledge, what there is particularly dead about a door-nail. I might have been inclined, myself, to regard a coffin-nail as the deadest piece of ironmongery in the trade. But the wisdom of our ancestors is in the simile; and my unhallowed hands shall not disturb it, or the Country''s done for. You will therefore permit me to repeat, emphatically, that Marley was as dead as a door-nail.')",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 3, 'mitchell', 'Scrooge knew he was dead? Of course he did. How could it be otherwise? Scrooge and he were partners for I don''t know how many years. Scrooge was his sole executor, his sole administrator, his sole assign, his sole residuary legatee, his sole friend, and sole mourner. And even Scrooge was not so dreadfully cut up by the sad event, but that he was an excellent man of business on the very day of the funeral, and solemnised it with an undoubted bargain.')",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 3, 'cary', 'The mention of Marley''s funeral brings me back to the point I started from. There is no doubt that Marley was dead. This must be distinctly understood, or nothing wonderful can come of the story I am going to relate. If we were not perfectly convinced that Hamlet''s Father died before the play began, there would be nothing more remarkable in his taking a stroll at night, in an easterly wind, upon his own ramparts, than there would be in any other middle-aged gentleman rashly turning out after dark in a breezy spot--say Saint Paul''s Churchyard for instance-- literally to astonish his son''s weak mind.')",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 3, 'justine', 'Scrooge never painted out Old Marley''s name. There it stood, years afterwards, above the warehouse door: Scrooge and Marley. The firm was known as Scrooge and Marley. Sometimes people new to the business called Scrooge Scrooge, and sometimes Marley, but he answered to both names. It was all the same to him.')",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 3, 'cary', 'Oh! But he was a tight-fisted hand at the grind-stone, Scrooge! a squeezing, wrenching, grasping, scraping,clutching, covetous, old sinner! Hard and sharp as flint,from which no steel had ever struck out generous fire;secret, and self-contained, and solitary as an oyster. The cold within him froze his old features, nipped his pointed nose, shrivelled his cheek, stiffened his gait; made his eyes red, his thin lips blue; and spoke out shrewdly in his grating voice. A frosty rime was on his head, and on his eyebrows, and his wiry chin. He carried his own low tmperature always about with him; he iced his office in the dog-days; and didn''t thaw it one degree at Christmas.')",
				
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 4, 'justine', 'Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, ''and what is the use of a book,'' thought Alice ''without pictures or conversation?''')",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 4, 'mitchell', 'So she was considering in her own mind (as well as she could, for the hot day madher feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.')",
				
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 1, 'justine', 'Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, ''and what is the use of a book,'' thought Alice ''without pictures or conversation?''')",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 5, 'mitchell', 'So she was considering in her own mind (as well as she could, for the hot day madher feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.')",
				
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 2, 'username', 'Hell hath no fury like a woman scorned' )",
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 1, 'cary', 'Hell hath no fury like a woman scorned' )",
				
				"INSERT INTO POST_TABLE(STORYID, USERID, POST) VALUES ( 6, 'ABCDEFG', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"
		};
		for( int i = 0; i < QueryList.length; i++ ) {
			DatabaseManager.executeUpdate( QueryList[i] );
			try {
				Thread.sleep(SLEEP_TIME);
			} catch(Exception e) {
				LogManager.logError( "[DatabaseUtility] - " + e.getMessage() );
			}
		}
	}
}


